************************************
*Table 1 - Members' Places of Birth 
************************************

*Select directory
use "House_BirthplaceData.dta"

*Column 1
bysort congress: count if born_indist==0
*Column 2
bysort congress: count if born_instate==0
*Column 3
bysort congress: count if born_inregion==0
*Column 4
bysort congress: count if birth_Abroad==1 | birthstateabbrev=="DC"

clear


*************************
*Table 2 - Balance Test 
*************************

*Select directory
use "House_BirthplaceData.dta"

duplicates drop icpsr_id, force

*BORN IN-STATE (Top rows of Table 2)

*All members - Column 1
logit born_instate AgeInteger Female Black Hispanic dpres i.birthstate_icpsr i.Rep_state_icpsr if congress<116
*Wald p
test AgeInteger Female Black Hispanic dpres

*All members - Column 2
logit born_instate AgeInteger Female Black Hispanic dpres nominate_dim1 ChamSeniority_Stew i.birthstate_icpsr i.Rep_state_icpsr if congress<116
*Wald p
test AgeInteger Female Black Hispanic dpres nominate_dim1 ChamSeniority_Stew

*Democrats - Column 3
logit born_instate AgeInteger Female Black Hispanic dpres i.birthstate_icpsr i.Rep_state_icpsr if congress<116 & party_code==100
*Wald p
test AgeInteger Female Black Hispanic dpres

*Democrats - Column 4
logit born_instate AgeInteger Female Black Hispanic dpres nominate_dim1 ChamSeniority_Stew i.birthstate_icpsr i.Rep_state_icpsr if congress<116 & party_code==100
*Wald p
test AgeInteger Female Black Hispanic dpres nominate_dim1 ChamSeniority_Stew

*Republicans - Column 5
logit born_instate AgeInteger Female Black Hispanic dpres i.birthstate_icpsr i.Rep_state_icpsr if congress<116 & party_code==200
*Wald p
test AgeInteger Female Black Hispanic dpres

*Republicans - Column 6
logit born_instate AgeInteger Female Black Hispanic dpres nominate_dim1 ChamSeniority_Stew i.birthstate_icpsr i.Rep_state_icpsr if congress<116 & party_code==200
*Wald p
test AgeInteger Female Black Hispanic dpres nominate_dim1 ChamSeniority_Stew


*BORN IN-REGION (Bottom rows of Table 2)

egen Rep_region_group=group(RepRegion)
egen Birth_region_group=group(BirthRegion)

*All members - Column 1
logit born_inregion AgeInteger Female Black Hispanic dpres i.Birth_region_group i.Rep_region_group if congress<116
*Wald p
test AgeInteger Female Black Hispanic dpres

*All members - Column 2
logit born_inregion AgeInteger Female Black Hispanic dpres nominate_dim1 ChamSeniority_Stew i.Birth_region_group i.Rep_region_group if congress<116
*Wald p
test AgeInteger Female Black Hispanic dpres nominate_dim1 ChamSeniority_Stew

*Democrats - Column 3
logit born_inregion AgeInteger Female Black Hispanic dpres i.Birth_region_group i.Rep_region_group if congress<116 & party_code==100
*Wald p
test AgeInteger Female Black Hispanic dpres

*Democrats - Column 4
logit born_inregion AgeInteger Female Black Hispanic dpres nominate_dim1 ChamSeniority_Stew i.Birth_region_group i.Rep_region_group if congress<116 & party_code==100
*Wald p
test AgeInteger Female Black Hispanic dpres nominate_dim1 ChamSeniority_Stew

*Republicans - Column 5
logit born_inregion AgeInteger Female Black Hispanic dpres i.Birth_region_group i.Rep_region_group if congress<116 & party_code==200
*Wald p
test AgeInteger Female Black Hispanic dpres

*Republicans - Column 6
logit born_inregion AgeInteger Female Black Hispanic dpres nominate_dim1 ChamSeniority_Stew i.Birth_region_group i.Rep_region_group if congress<116 & party_code==200
*Wald p
test AgeInteger Female Black Hispanic dpres nominate_dim1 ChamSeniority_Stew

clear


************************************
*Table 3 - Agreement Scores Models 
************************************

*Select directory
use "House_AgreementScoreData.dta"
gen BirthDistanceMiles=BirthDistance/1609.34
gen RepDistanceMiles=RepDistance/1609.34

*Best fitting model (Model 6) must be executed first
quietly fracreg logit Agree c.Age##i.BirthRegion c.Age##c.BirthDistanceMiles RepRegion RepDistanceMiles Party Gender Race DPres ChamSeniority i.congress, vce(robust)
quietly estat ic
quietly mat s=r(S)
quietly scalar aic6=s[1,5]
quietly di aic6-aic6
quietly scalar aicc6=aic6+(2*e(df_m)*(e(df_m)+1))/(e(N)-e(df_m)-1)
quietly di aicc6-aicc6

*Model 1
fracreg logit Agree c.Age##i.BirthState RepState Party Gender Race DPres ChamSeniority i.congress, vce(robust)
estat ic
mat s=r(S)
scalar aic1=s[1,5]
di aic1-aic6
scalar aicc1=aic1+(2*e(df_m)*(e(df_m)+1))/(e(N)-e(df_m)-1)
scalar C16=aicc1-aicc6
*Change in AICc
di C16
*Checking Conditional Significance of State x Age Interaction 
*fracreg logit Agree c.Age##i.BirthState RepState Party Gender Race DPres ChamSeniority i.congress, vce(robust)
*margins, at(Age=(0 5 10 17 37) BirthState=(0 1)) atmeans level(84) post
*Statistically significant difference between in-out birth state for all except the highest category of age

*Model 2
fracreg logit Agree c.Age##i.BirthRegion RepRegion Party Gender Race DPres ChamSeniority i.congress, vce(robust)
estat ic
mat s=r(S)
scalar aic2=s[1,5]
di aic2-aic6
scalar aicc2=aic2+(2*e(df_m)*(e(df_m)+1))/(e(N)-e(df_m)-1)
scalar C26=aicc2-aicc6
*Change in AICc
di C26

*Model 3
fracreg logit Agree c.Age##c.BirthDistanceMiles RepDistanceMiles Party Gender Race DPres ChamSeniority i.congress, vce(robust)
estat ic
mat s=r(S)
scalar aic3=s[1,5]
di aic3-aic6
scalar aicc3=aic3+(2*e(df_m)*(e(df_m)+1))/(e(N)-e(df_m)-1)
scalar C36=aicc3-aicc6
*Change in AICc
di C36

*Model 4
fracreg logit Agree c.Age##i.BirthState c.Age##i.BirthRegion RepState RepRegion Party Gender Race DPres ChamSeniority i.congress, vce(robust)
estat ic
mat s=r(S)
scalar aic4=s[1,5]
di aic4-aic6
scalar aicc4=aic4+(2*e(df_m)*(e(df_m)+1))/(e(N)-e(df_m)-1)
scalar C46=aicc4-aicc6
*Change in AICc
di C46
*Checking Conditional Significance of State x Age Interaction 
*fracreg logit Agree c.Age##i.BirthState c.Age##i.BirthRegion RepState RepRegion Party Gender Race DPres ChamSeniority i.congress, vce(robust)
*margins, at(Age=(0 5 10 17 37) BirthState=(0 1)) atmeans level(84) post
*Not statistically significant at any level of age


*Model 5
fracreg logit Agree c.Age##i.BirthState c.Age##c.BirthDistanceMiles RepState RepDistanceMiles Party Gender Race DPres ChamSeniority i.congress, vce(robust)
estat ic
mat s=r(S)
scalar aic5=s[1,5]
di aic5-aic6
scalar aicc5=aic5+(2*e(df_m)*(e(df_m)+1))/(e(N)-e(df_m)-1)
scalar C56=aicc5-aicc6
*Change in AICc
di C56
*Checking Conditional Significance of State x Age Interaction 
*fracreg logit Agree c.Age##BirthState c.Age##c.BirthDistanceMiles RepState RepDistanceMiles Party Gender Race DPres ChamSeniority i.congress, vce(robust)
*margins, at(Age=(0 5 10 17 37) BirthState=(0 1)) atmeans level(84) post
*Not statistically significant at any level of age

*Model 6
*BEST FIT (using AIC and AICc, which converge on large n)
fracreg logit Agree c.Age##i.BirthRegion c.Age##c.BirthDistanceMiles RepRegion RepDistanceMiles Party Gender Race DPres ChamSeniority i.congress, vce(robust)
estat ic
mat s=r(S)
scalar aic6=s[1,5]
di aic6-aic6
scalar aicc6=aic6+(2*e(df_m)*(e(df_m)+1))/(e(N)-e(df_m)-1)
scalar C66=aicc6-aicc6
*Change in AICc
di C66

*Model 7
fracreg logit Agree c.Age##i.BirthState c.Age##i.BirthRegion c.Age##c.BirthDistanceMiles RepState RepRegion RepDistanceMiles Party Gender Race DPres ChamSeniority i.congress, vce(robust)
estat ic
mat s=r(S)
scalar aic7=s[1,5]
di aic7-aic6
scalar aicc7=aic7+(2*e(df_m)*(e(df_m)+1))/(e(N)-e(df_m)-1)
scalar C76=aicc7-aicc6
*Change in AICc
di C76
*Checking Conditional Significance of State x Age Interaction 
*fracreg logit Agree c.Age##BirthState c.Age##BirthRegion c.Age##c.BirthDistanceMiles RepState RepRegion RepDistanceMiles Party Gender Race DPres ChamSeniority i.congress, vce(robust)
*margins, at(Age=(0 5 10 17 37) BirthState=(0 1)) atmeans level(84) post
*Not statistically significant at any level of age

*Calculating w_i (i.e., Probability of best model)
scalar E1=exp(-.5*C16)
scalar E2=exp(-.5*C26)
scalar E3=exp(-.5*C36)
scalar E4=exp(-.5*C46)
scalar E5=exp(-.5*C56)
scalar E6=exp(-.5*C66)
scalar E7=exp(-.5*C76)

scalar W1=(E1)/(E1+E2+E3+E4+E5+E6+E7)
scalar W2=(E2)/(E1+E2+E3+E4+E5+E6+E7)
scalar W3=(E3)/(E1+E2+E3+E4+E5+E6+E7)
scalar W4=(E4)/(E1+E2+E3+E4+E5+E6+E7)
scalar W5=(E5)/(E1+E2+E3+E4+E5+E6+E7)
scalar W6=(E6)/(E1+E2+E3+E4+E5+E6+E7)
scalar W7=(E7)/(E1+E2+E3+E4+E5+E6+E7)

di W1
di W2
di W3
di W4
di W5
di W6
di W7

clear


************************************************************
*Agreement Scores Models, High School Restriction - Table 4
************************************************************

*Same analysis as above, but restricting observations to those members who attended high school in the same county as their birth.

*Select directory
use "House_AgreementScoreData.dta"
keep if HSsamecountyMin==1 & HSsamecountyMax==1
gen BirthDistanceMiles=BirthDistance/1609.34
gen RepDistanceMiles=RepDistance/1609.34

*Best fitting model (Model 3) must be executed first
quietly fracreg logit Agree c.Age##c.BirthDistanceMiles RepDistanceMiles Party Gender Race DPres ChamSeniority i.congress, vce(robust)
quietly estat ic
quietly mat s=r(S)
quietly scalar aic3=s[1,5]
quietly di aic3-aic3
quietly scalar aicc3=aic3+(2*e(df_m)*(e(df_m)+1))/(e(N)-e(df_m)-1)
quietly di aicc3-aicc3

*Model 1
fracreg logit Agree c.Age##i.BirthState RepState Party Gender Race DPres ChamSeniority i.congress, vce(robust)
estat ic
mat s=r(S)
scalar aic1=s[1,5]
di aic1-aic3
scalar aicc1=aic1+(2*e(df_m)*(e(df_m)+1))/(e(N)-e(df_m)-1)
scalar C13=aicc1-aicc3
*Change in AICc
di C13
*Checking Conditional Significance of State x Age Interaction 
*fracreg logit Agree c.Age##i.BirthState RepState Party Gender Race DPres ChamSeniority i.congress, vce(robust)
*margins, at(Age=(0 5 10 17 37) BirthState=(0 1)) atmeans level(84) post
*Statistically significant difference between in-out birth state for all except the highest category of age

*Model 2
fracreg logit Agree c.Age##i.BirthRegion RepRegion Party Gender Race DPres ChamSeniority i.congress, vce(robust)
estat ic
mat s=r(S)
scalar aic2=s[1,5]
di aic2-aic3
scalar aicc2=aic2+(2*e(df_m)*(e(df_m)+1))/(e(N)-e(df_m)-1)
scalar C23=aicc2-aicc3
*Change in AICc
di C23

*Model 3
*BEST FIT (using AIC and AICc, which converge on large n)
fracreg logit Agree c.Age##c.BirthDistanceMiles RepDistanceMiles Party Gender Race DPres ChamSeniority i.congress, vce(robust)
estat ic
mat s=r(S)
scalar aic3=s[1,5]
di aic3-aic3
scalar aicc3=aic3+(2*e(df_m)*(e(df_m)+1))/(e(N)-e(df_m)-1)
scalar C33=aicc3-aicc3
*Change in AICc
di C33

*Model 4
fracreg logit Agree c.Age##i.BirthState c.Age##i.BirthRegion RepState RepRegion Party Gender Race DPres ChamSeniority i.congress, vce(robust)
estat ic
mat s=r(S)
scalar aic4=s[1,5]
di aic4-aic3
scalar aicc4=aic4+(2*e(df_m)*(e(df_m)+1))/(e(N)-e(df_m)-1)
scalar C43=aicc4-aicc3
*Change in AICc
di C43

*Model 5
fracreg logit Agree c.Age##i.BirthState c.Age##c.BirthDistanceMiles RepState RepDistanceMiles Party Gender Race DPres ChamSeniority i.congress, vce(robust)
estat ic
mat s=r(S)
scalar aic5=s[1,5]
di aic5-aic3
scalar aicc5=aic5+(2*e(df_m)*(e(df_m)+1))/(e(N)-e(df_m)-1)
scalar C53=aicc5-aicc3
*Change in AICc
di C53
*Checking Conditional Significance of State x Age Interaction 
*fracreg logit Agree c.Age##BirthState c.Age##c.BirthDistanceMiles RepState RepDistanceMiles Party Gender Race DPres ChamSeniority i.congress, vce(robust)
*margins, at(Age=(0 5 10 17 37) BirthState=(0 1)) atmeans level(84) post
*Not statistically significant at any level of age

*Model 6
fracreg logit Agree c.Age##i.BirthRegion c.Age##c.BirthDistanceMiles RepRegion RepDistanceMiles Party Gender Race DPres ChamSeniority i.congress, vce(robust)
estat ic
mat s=r(S)
scalar aic6=s[1,5]
di aic6-aic3
scalar aicc6=aic6+(2*e(df_m)*(e(df_m)+1))/(e(N)-e(df_m)-1)
scalar C63=aicc6-aicc3
*Change in AICc
di C63

*Model 7
fracreg logit Agree c.Age##i.BirthState c.Age##i.BirthRegion c.Age##c.BirthDistanceMiles RepState RepRegion RepDistanceMiles Party Gender Race DPres ChamSeniority i.congress, vce(robust)
estat ic
mat s=r(S)
scalar aic7=s[1,5]
di aic7-aic3
scalar aicc7=aic7+(2*e(df_m)*(e(df_m)+1))/(e(N)-e(df_m)-1)
scalar C73=aicc7-aicc3
*Change in AICc
di C73

*Calculating w_i (i.e., Probability of best model)
scalar E1=exp(-.5*C13)
scalar E2=exp(-.5*C23)
scalar E3=exp(-.5*C33)
scalar E4=exp(-.5*C43)
scalar E5=exp(-.5*C53)
scalar E6=exp(-.5*C63)
scalar E7=exp(-.5*C73)

scalar W1=(E1)/(E1+E2+E3+E4+E5+E6+E7)
scalar W2=(E2)/(E1+E2+E3+E4+E5+E6+E7)
scalar W3=(E3)/(E1+E2+E3+E4+E5+E6+E7)
scalar W4=(E4)/(E1+E2+E3+E4+E5+E6+E7)
scalar W5=(E5)/(E1+E2+E3+E4+E5+E6+E7)
scalar W6=(E6)/(E1+E2+E3+E4+E5+E6+E7)
scalar W7=(E7)/(E1+E2+E3+E4+E5+E6+E7)

di W1
di W2
di W3
di W4
di W5
di W6
di W7

clear


*****************************************
*Agriculture Protection Models - Table 5
*****************************************

*Friend of the Farm Bureau Models

*Select directory
use "AgricultureData_AgBirth.dta"

*Column 1
regress friend career prop_ag ln_ag_pac dist_povertypct dist_mednhhincome house_ag rep ideology female age state_fe_* cong_* if chamber_2==0, vce(cluster icpsr_id)

*Column 2 
*Normalized (to unit interval) croplandharvested_acres
sum croplandharvested_acres
return list
gen cropmean=r(mean)
gen cropsd=r(sd)
gen cropmax=r(max)
gen cropmin=0
gen crop_Unit=1/cropmax*(croplandharvested_acres-cropmax)+1

regress friend crop_Unit career prop_ag ln_ag_pac dist_povertypct dist_mednhhincome house_ag rep ideology female age state_fe_* cong_* if chamber_2==0, vce(cluster icpsr_id)

*Column 3
*Standardized coefficients
regress friend crop_Unit career prop_ag ln_ag_pac dist_povertypct dist_mednhhincome house_ag rep ideology female age state_fe_* cong_* if chamber_2==0, beta
stdBeta

clear

*Agriculture Protection Ideal Point Models

*Select directory
use "AgricultureData_Ideal.dta"

*Normalized (to unit interval) croplandharvested_acres
sum croplandharvested_acres
return list
gen cropmean=r(mean)
gen cropsd=r(sd)
gen cropmax=r(max)
gen cropmin=0
gen crop_Unit=1/cropmax*(croplandharvested_acres-cropmax)+1

*Column 4
regress AgIdeal_Unit crop_Unit career dist_povertypct dist_mednhhincome house_ag rep ideology female age i.state_icpsr i.TimeNum, vce(cluster icpsr_id)
*Column 5
regress AgIdeal_Unit crop_Unit prop_ag dist_povertypct dist_mednhhincome house_ag rep ideology female age i.state_icpsr i.TimeNum, vce(cluster icpsr_id)
*Column 6
regress AgIdeal_Unit crop_Unit ln_ag_pac dist_povertypct dist_mednhhincome house_ag rep ideology female age i.state_icpsr i.TimeNum, vce(cluster icpsr_id)
*Column 7
regress AgIdeal_Unit crop_Unit career prop_ag ln_ag_pac dist_povertypct dist_mednhhincome house_ag rep ideology female age i.state_icpsr i.TimeNum, vce(cluster icpsr_id)

clear



